﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Globalization;


[XmlRootAttribute("gbXML", Namespace = "http://www.gbxml.org/schema", IsNullable = false)]
[Serializable]
public partial class gbXML
{
    [XmlAttribute] 
    private temperatureUnitEnum temperatureUnitField;
    [XmlAttribute]
    private lengthUnitEnum lengthUnitField;

    
    
    [XmlAttributeAttribute()]
    public temperatureUnitEnum temperatureUnit {
        get {
            return this.temperatureUnitField;
        }
        set {
            this.temperatureUnitField = value;
        }
    }

    [XmlAttributeAttribute()]
    public lengthUnitEnum lengthUnit
    {
        get
        {
            return this.lengthUnitField;
        }
        set
        {
            this.lengthUnitField = value;
        }
    }




    [Serializable]
    public partial class Length
    {

        private lengthUnitEnum unitField;

        private bool unitFieldSpecified;

        private decimal valueField;

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public lengthUnitEnum unit
        {
            get
            {
                return this.unitField;
            }
            set
            {
                this.unitField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public bool unitSpecified
        {
            get
            {
                return this.unitFieldSpecified;
            }
            set
            {
                this.unitFieldSpecified = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlTextAttribute()]
        public decimal Value
        {
            get
            {
                return this.valueField;
            }
            set
            {
                this.valueField = value;
            }
        }
    }

    [Serializable]
    public enum temperatureUnitEnum
    {

        /// <remarks/>
        F,

        /// <remarks/>
        C,

        /// <remarks/>
        K,

        /// <remarks/>
        R,
    }

    public Campus Campus;

}

public class Area
{
    [XmlText]
    public string val { get; set; }
}

[Serializable]
[XmlRootAttribute(ElementName = "gbXML", IsNullable = true, Namespace = "http://www.gbxml.org/schema")]
public class Campus
{
    [XmlAttribute]
    public string id;
    public Location Location;
    [XmlElement(ElementName = "Building", IsNullable = false)]
    public Building[] Buildings { get; set; }
    [XmlElement(ElementName = "Surface", IsNullable = false)]
    public Surface[] Surface { get; set; }


}

[Serializable]
[XmlRootAttribute(ElementName = "gbXML", IsNullable = true, Namespace = "http://www.gbxml.org/schema")]
public class Location
{
    public string Name {get;set;}
    public double Latitude {get; set;}
    public double Longitude {get; set;}
}

[Serializable]

[XmlRootAttribute(ElementName = "gbXML", IsNullable = true, Namespace = "http://www.gbxml.org/schema")]
public class Building
{
    [XmlAttribute]
    public string id { get; set; }
    [XmlAttribute]
    public string buildingType { get; set; }
    public double Area { get; set; }
    [XmlElement("BuildingStorey")]
    public BuildingStorey[] bldgStories { get; set; }
    [XmlElement("Space")]
    public Space[] Spaces { get; set; }
}

[Serializable]
[XmlRootAttribute(ElementName = "gbXML", IsNullable = true, Namespace = "http://www.gbxml.org/schema")]
public class BuildingStorey
{
    [XmlAttribute]
    public string id { get; set; }
    public string Name { get; set; }
    public double Level { get; set; }
    [XmlElement("PlanarGeometry")]
    public PlanarGeometry PlanarGeo { get; set; }
}

[Serializable]
public class CADObjectId
{
    [XmlText]
    public string id { get; set; }
}

[Serializable]
public class PlanarGeometry
{
    
    public PolyLoop PolyLoop { get; set; }
}

[Serializable]
public class PolyLoop
{
    [XmlElement(IsNullable = false, ElementName="CartesianPoint")]
    public CartesianPoint[] Points { get; set; }
}

[Serializable]
[XmlRootAttribute(ElementName = "gbXML", IsNullable = false, Namespace = "http://www.gbxml.org/schema")]
public class CartesianPoint
{
    [XmlElement(ElementName="Coordinate", IsNullable=false)]
    public string[] Coordinate;
}

[Serializable]
[XmlRootAttribute(ElementName = "gbXML", IsNullable = false, Namespace = "http://www.gbxml.org/schema")]
public class Space
{
    [XmlAttribute]
    public string id;
    [XmlAttribute]
    public string zoneIdRef;
    [XmlAttribute]
    public string lightScheduleIdRef;
    [XmlAttribute]
    public string equipmentScheduleIdRef;
    [XmlAttribute]
    public string peopleScheduleIdRef;
    [XmlAttribute]
    public string conditionType;
    [XmlAttribute]
    public string buildingStoreyIdRef;

    public string Name { get; set; }
    public PeopleNumber PeopleNumber { get; set; }
    [XmlElement("PeopleHeatGain")]
    public PeopleHeatGain[] PeopleHeatGains { get; set; }
    [XmlIgnore]
    public double peoplenum { get; set; }
    [XmlIgnore]
    public double totalpeoplegain { get; set; }
    [XmlIgnore]
    public double senspeoplegain { get; set; }
    [XmlIgnore]
    public double latpeoplegain { get; set; }

    public LightPowerPerArea LightPowerPerArea { get; set; }
    [XmlIgnore]
    public double lpd { get; set; }
    public EquipPowerPerArea EquipPowerPerArea { get; set; }
    [XmlIgnore]
    public double epd { get; set; }

    [XmlIgnore]
    public double Area { get; set; }
    [XmlElement("Area")]
    public Area spacearea { get; set; }

    [XmlIgnore]
    public double Volume { get; set; }
    [XmlElement("Volume")]
    public Volume spacevol { get; set; }

    [XmlElement("PlanarGeometry")]
    public PlanarGeometry PlanarGeo { get; set; }
    [XmlElement("ShellGeometry")]
    public ShellGeometry ShellGeo { get; set; }
    [XmlElement("CADObjectId")]
    public CADObjectId cadid { get; set; }
    [XmlElement("SpaceBoundary")]
    public SpaceBoundary[] spbound { get; set; }
}

[Serializable]
public class SpaceBoundary
{
    [XmlAttribute]
    public string surfaceIdRef { get; set; }
    public PlanarGeometry PlanarGeometry { get; set; }
}

public class LightPowerPerArea
{
    [XmlAttribute]
    public powerPerAreaUnitEnum unit { get; set; }
    [XmlText]
    public string lpd { get; set; }
}

public class EquipPowerPerArea
{
    [XmlAttribute]
    public powerPerAreaUnitEnum unit { get; set; }
    [XmlText]
    public string epd { get; set; }
}

public class PeopleNumber
{
    [XmlAttribute]
    public peopleNumberUnitEnum peopleunits { get; set; }
    public string progidfield { get; set; }
    [XmlText]
    public string valuefield { get; set; }
}

public class PeopleHeatGain
{
    [XmlAttribute]
    public peopleHeatGainUnitEnum loadunits { get; set; }
    [XmlAttribute]
    public peopleHeatGainTypeEnum loadtype { get; set; }
    public string programidfield { get; set; }
    [XmlText]
    public string value { get; set; }
}

public class ShellGeometry
{
    [XmlAttribute]
    public string id { get; set; }
    [XmlAttribute]
    public lengthUnitEnum unit { get; set; }
    public ClosedShell ClosedShell;
}

[Serializable]
public class ClosedShell
{
    [XmlElement(IsNullable = false, ElementName = "PolyLoop")]
    public PolyLoop[] PolyLoops { get; set; }
}


public class Volume
{
    [XmlText]
    public string val { get; set; }
}


[Serializable]
public class Surface
{
    [XmlAttribute]
    public string id { get; set; }
    [XmlAttribute]
    public surfaceTypeEnum surfaceType { get; set; }
    [XmlAttribute]
    public string constructionIdRef { get; set; }
    public string Name { get; set; }
    [XmlElement(IsNullable = false, ElementName = "AdjacentSpaceId")]
    public AdjacentSpaceId[] AdjacentSpaceId { get; set; }
    public RectangularGeometry RectangularGeometry { get; set; }
    public PlanarGeometry PlanarGeometry { get; set; }
    [XmlIgnore]
    public bool exposedToSunField;
    public string CADObjectId { get; set; }
}

[Serializable]
public class AdjacentSpaceId
{
    [XmlAttribute]
    public string spaceIdRef { get; set; }
    //why?
    public surfaceTypeEnum surfaceTypeField {get; set; }
    //why?
    [XmlIgnore]
    public bool surfaceTypeFieldSpecified { get; set; }
}

[Serializable]
public class RectangularGeometry
{
    public string Azimuth { get; set; }
    public CartesianPoint CartesianPoint { get; set; }
    public string Tilt { get; set; }
    public string Height { get; set; }
    public string Width { get; set; }
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.gbxml.org/schema")]
public enum peopleHeatGainTypeEnum
{

    /// <remarks/>
    Total,

    /// <remarks/>
    Sensible,

    /// <remarks/>
    Latent,
}

[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.gbxml.org/schema")]
public enum peopleHeatGainUnitEnum {
    
    /// <remarks/>
    WattPerPerson,
    
    /// <remarks/>
    BtuPerHourPerson,
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.gbxml.org/schema")]
public enum peopleNumberUnitEnum {
    
    /// <remarks/>
    NumberOfPeople,
    
    /// <remarks/>
    SquareFtPerPerson,
    
    /// <remarks/>
    SquareMPerPerson,
}


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.gbxml.org/schema")]
public enum powerPerAreaUnitEnum
{

    /// <remarks/>
    WattPerSquareMeter,

    /// <remarks/>
    WattPerSquareFoot,
}


[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.gbxml.org/schema")]
public enum lengthUnitEnum
{

    /// <remarks/>
    Kilometers,

    /// <remarks/>
    Meters,

    /// <remarks/>
    Centimeters,

    /// <remarks/>
    Millimeters,

    /// <remarks/>
    Miles,

    /// <remarks/>
    Yards,

    /// <remarks/>
    Feet,

    /// <remarks/>
    Inches,
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.gbxml.org/schema")]
public enum surfaceTypeEnum
{

    /// <remarks/>
    InteriorWall,

    /// <remarks/>
    ExteriorWall,

    /// <remarks/>
    Roof,

    /// <remarks/>
    InteriorFloor,

    /// <remarks/>
    Shade,

    /// <remarks/>
    UndergroundWall,

    /// <remarks/>
    UndergroundSlab,

    /// <remarks/>
    Ceiling,

    /// <remarks/>
    Air,

    /// <remarks/>
    UndergroundCeiling,

    /// <remarks/>
    RaisedFloor,

    /// <remarks/>
    SlabOnGrade,

    /// <remarks/>
    FreestandingColumn,

    /// <remarks/>
    EmbeddedColumn,
}

public static class gb
{
    public static CultureInfo gbci;
    //this should not be serializable
    public static string FormatDoubleToString(double number)
    {
        
        string ret;
        ret = string.Format(gb.gbci, "{0:0.000000}", number);
        return ret;
    }
}